Core.Test.registerTest({
	group: "dao",
	name: "Core.Storage.Configuration notify",
	
	before: function() {
		this.registry = { propertyChanged: function() {} };
		this.conf = new Core.Storage.Configuration(this.registry);
	},
	
	"Should notify listeners on visible override (same priority)": function() {
		Assert.that(this.registry).invokes("propertyChanged").args("prop");
		
		this.conf.override("prop", 10, this, 20);
		Assert.verify();
	},
	
	"Should notify listeners on visible, resolved conflicted override": function() {
		var stub = { resolveOverrideConflict: function() { return true; }};
		Assert.that(this.registry).invokes("propertyChanged").args("prop").calls(2);
		

		this.conf.override("prop", 10, stub, 20);
		this.conf.override("prop", 15, this, 20);
		Assert.verify();
	},

	"Should notify listeners on visible override (different priorities)": function() {
		Assert.that(this.registry).invokes("propertyChanged").args("prop").calls(3);
		
		this.conf.override("prop", 10, this, 20);
		this.conf.override("prop", 15, this, 15);
		this.conf.override("prop", 20, this, 10);
		Assert.verify();
	},
	
	"Should notify listeners on visible clear override (1)": function() {
		this.conf.override("prop", 10, this, 20);
		
		Assert.that(this.registry).invokes("propertyChanged").args("prop");
		this.conf.clearOverride("prop", this, 20);
		Assert.verify();
	},
	
	"Should notify listeners on visible clear override (2)": function() {
		this.conf.override("prop", 10, this, 20);
		this.conf.override("prop", 10, this, 15);
		
		Assert.that(this.registry).invokes("propertyChanged").args("prop");
		this.conf.clearOverride("prop", this, 15);
		Assert.verify();
	},
	
	"Shouldn't notify listeners on hidden override": function() {
		this.conf.override("prop", 10, this, 0);
		
		Assert.that(this.registry).invokes("propertyChanged").args("prop").calls(0);
		this.conf.override("prop", 10, this, 20);
		this.conf.override("prop", 10, this, 15);
		this.conf.override("prop", 10, this, 10);
		Assert.verify();
	},
	
	"Shouldn't notify listeners on hidden clear override": function() {
		this.conf.override("prop", 10, this, 0);
		this.conf.override("prop", 10, this, 5);
		this.conf.override("prop", 10, this, 10);
		
		Assert.that(this.registry).invokes("propertyChanged").args("prop").calls(0);
		this.conf.clearOverride("prop", this, 10);
		this.conf.clearOverride("prop", this, 5);
		Assert.verify();
	},
	
	"Shouldn't notify listeners on ignored clear override": function() {
		this.conf.override("prop", 10, this, 20);
		
		Assert.that(this.registry).invokes("propertyChanged").args("prop").calls(0);
		this.conf.clearOverride("prop", window, 20);
		Assert.verify();
	}
});